package com.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mall.db.domain.Order;
import com.mall.db.service.OrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/oc")
public class OrderController extends BaseController<Order>{

    @Resource(name="orderService")
    private OrderService os;

    @Override
    public Map<String, Object> find(Order order) {
        //实现分页
        PageHelper.startPage(order.getPage(),order.getLimit());

        QueryWrapper<Order> qw = new QueryWrapper<>();
        List<Order> list = os.list(qw);

        PageInfo<Order> page = new PageInfo<>(list,order.getLimit());

        return this.findMap(page.getList(), page.getTotal());
    }
}
